package com.ricky.service_hospital.controller;

import com.ricky.common_util.result.Result;
import com.ricky.hosp.model.hosp.Hospital;
import com.ricky.hosp.vo.hosp.HospitalQueryVo;
import com.ricky.service_hospital.service.HospitalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


@RestController
@RequestMapping("/admin/hosp/hospital")
//@CrossOrigin
@Api(tags = "医院查询接口")
public class HospitalController {
    @Autowired
    HospitalService hospitalService;
    //医院列表（条件查询带分页）
    @ApiOperation(value = "查询医院列表（带分页）")
    @PostMapping("/list/{page}/{limit}")
    public Result listHosp(@PathVariable Integer page, @PathVariable Integer limit, @RequestBody(required = false) HospitalQueryVo hospitalQueryVo){
        Page<Hospital> pageModel = hospitalService.selectHospPage(page,limit,hospitalQueryVo);
        return Result.ok(pageModel);
    }
    @ApiOperation(value = "更新医院上线状态")
    @GetMapping("updateHospStatus/{id}/{status}")
    public Result lock(@PathVariable String id, @PathVariable Integer status){
        hospitalService.updateStates(id,status);
        return Result.ok();
    }
    @ApiOperation(value = "医院详情信息")
    @GetMapping("showHospDetail/{id}")
    public Result showHospDetail(@PathVariable String id){
        Map<String,Object> map = hospitalService.getHospById(id);
        return Result.ok(map);
    }
}
